<template>
  <div class="app-container">
    <el-tabs v-model="activeName">
      <el-tab-pane label="原纸采购单" name="first">
         <!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
           <el-form-item label="采购订单号">
             <el-input v-model="queryParams.purchaseOrderNumber" clearable placeholder="请输入采购订单号"></el-input>
           </el-form-item>
           <el-form-item label="供应商">
             <el-input v-model="queryParams.purchaseSupplier" clearable placeholder="请输入供应商"></el-input>
           </el-form-item>
           <el-form-item label="采购业务员">
             <el-input v-model="queryParams.purchaseSalesman" clearable placeholder="请输入采购业务员"></el-input>
           </el-form-item>
           <el-form-item label="运输方式">
             <el-input v-model="queryParams.purchaseTransportation" clearable placeholder="请输入运输方式"></el-input>
           </el-form-item>
           <el-form-item label="对应生产任务单号">
             <el-input v-model="queryParams.purchaseProductionTaskNumber" clearable placeholder="请输入对应生产任务单号"></el-input>
           </el-form-item>
           <el-form-item label="对应销售单号">
             <el-input v-model="queryParams.purchaseSaleOrderNumber" clearable placeholder="请输入对应销售单号"></el-input>
           </el-form-item>
           <el-form-item label="对应合同号">
             <el-input v-model="queryParams.purchaseContractNumber" clearable placeholder="请输入对应合同号"></el-input>
           </el-form-item>
           <el-form-item>
             <el-button type="primary" @click="getList">查询</el-button>
             <el-button type="primary" @click="resetForm">重置</el-button>
           </el-form-item>
         </el-form> -->
        <el-row class="mb8">
          <el-col :span="1.5">
              <el-button type="primary" @click="handleAddPaperPurchase">新增</el-button>
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>
        <el-tooltip placement="top">
        <div slot="content">点击任意一行列，即可在下方查看明细信息记录</div>
        <el-table :data="paperPurchaseList" v-loading="loadingPaperPurchase" :row-class-name="rowClassName" @row-click="showTab" >
           <el-table-column type="selection" width="55" />
           <el-table-column align="center" label="采购订单号" prop="purchaseOrderNumber"/>
           <el-table-column align="center" label="订单日期" prop="purchaseDate"/>
           <el-table-column align="center" label="供应商" prop="purchaseSupplier"/>
           <el-table-column align="center" label="采购业务员" prop="purchaseSalesman"/>
           <el-table-column align="center" label="运输方式" prop="purchaseTransportation"/>
           <el-table-column align="center" label="对应生产任务单号" prop="purchaseProductionTaskNumber"/>
           <el-table-column align="center" label="对应销售单号" prop="purchaseSaleOrderNumber"/>
           <el-table-column align="center" label="对应合同号" prop="purchaseContractNumber"/>
           <el-table-column align="center" label="操作" fixed="right" width="150">
             <template slot-scope="scope">
               <el-button type="text" @click="handleUpdatePaperPurchase(scope.row)">修改</el-button>
               <el-button type="text" @click="handleDeletePaperPurchase(scope.row)">删除</el-button>
             </template>
           </el-table-column>
        </el-table>
        </el-tooltip>
      
      <pagination :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"
      :total="total" />
      
      <el-tabs>
        <el-tab-pane v-show="showProductionTask">
         <h2 align="center">(原纸)采购单明细信息</h2>
         <el-row class="mb8">
           <el-col :span="1.5">
              <el-button type="primary" @click="handleAddProductionTask">新增</el-button>
           </el-col>
         </el-row>
          <el-table :data="productionTaskList" v-loading="loadingProductionTask">
          <el-table-column align="center" label="版号" prop="paperNumber"/>
          <el-table-column align="center" label="需求数量" prop="paperQuantity"/>
          <el-table-column align="center" label="比例" prop="paperRatio"/>
          <el-table-column align="center" label="实际下单数" prop="paperActualQuantity"/>
          <el-table-column align="center" label="交货日期" prop="paperDeliveryDate"/>
          <el-table-column align="center" label="备注" prop="paperRemarks"/>
          <el-table-column align="center" label="操作" fixed="right" width="150">
            <template slot-scope="scope">
              <el-button type="text" @click="handleUpdateProductionTask(scope.row)">修改</el-button>
              <el-button type="text" @click="handleDeleteProductionTask(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      </el-tabs>
      </el-tab-pane>
      
      <el-tab-pane label="辅料采购单" name="second">
        <el-row class="mb8">
          <el-col :span="1.5">
              <el-button type="primary" @click="handleAddSupplementaryPurchase">新增</el-button>
          </el-col>
        </el-row>
        <el-tooltip placement="top">
        <div slot="content">点击任意一行列即可跳转查看记录</div>
        <el-table :data="supplementaryPurchaseList" v-loading="loadingSupplementaryPurchase" :row-class-name="rowClassNameOne" @row-click="showTab">
           <el-table-column type="selection" width="55" />
           <el-table-column align="center" label="采购订单号" prop="supplementaryPurchaseOrderNumber"/>
           <el-table-column align="center" label="订单日期" prop="SupplementaryPurchaseDate"/>
           <el-table-column align="center" label="供应商" prop="supplementaryPurchaseSupplier"/>
           <el-table-column align="center" label="采购业务员" prop="supplementaryPurchaseSalesman"/>
           <el-table-column align="center" label="运输方式" prop="supplementaryPurchaseTransportation"/>
           <el-table-column align="center" label="对应生产任务单号" prop="supplementaryPurchaseProductionTaskNumber"/>
           <el-table-column align="center" label="对应销售单号" prop="supplementaryPurchaseSaleOrderNumber"/>
           <el-table-column align="center" label="对应合同号" prop="supplementaryPurchaseContractNumber"/>
           <el-table-column align="center" label="操作" fixed="right" width="150">
             <template slot-scope="scope">
               <el-button type="text" @click="handleUpdateSupplementaryPurchase(scope.row)">修改</el-button>
              <el-button type="text" @click="handleDeleteSupplementaryPurchase(scope.row)">删除</el-button>
             </template>
           </el-table-column>
        </el-table>
        </el-tooltip>
      
      <pagination :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList"
      :total="total" />
      
      <el-tabs>
        <el-tab-pane v-show="showProductionTask">
         <h2 align="center">(辅料)采购单明细信息</h2>
         <el-row class="mb8">
           <el-col :span="1.5">
              <el-button type="primary" @click="handleAddSupplementaryProductionTask">新增</el-button>
           </el-col>
         </el-row>
        <el-table :data="supplementaryProductionTaskList" v-loading="loadingSupplementaryProductionTask">
          <el-table-column align="center" label="物品编号" prop="supplementaryNumber"/>
          <el-table-column align="center" label="名称">
          <el-table-column align="center" label="纸箱" prop="supplementaryBox"/>
          <el-table-column align="center" label="袋子" prop="supplementaryBag"/>
          <el-table-column align="center" label="彩盒" prop="supplementaryEnvelope"/>
          <el-table-column align="center" label="条码" prop="supplementaryBarcode"/>
          </el-table-column>
          <el-table-column align="center" label="规格" prop="supplementarySpecification"/>
          <el-table-column align="center" label="单位数量" prop="supplementaryUnitQuantity"/>
          <el-table-column align="center" label="副单位数量" prop="supplementarySubUnitQuantity"/>
          <el-table-column align="center" label="操作" fixed="right" width="150">
            <template slot-scope="scope">
              <el-button type="text" @click="handleUpdateSupplementaryProductionTask(scope.row)">修改</el-button>
              <el-button type="text" @click="handleDeleteSupplementaryProductionTask(scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      </el-tabs>
      </el-tab-pane>
    </el-tabs>
    
    <!-- 新增原材料采购单框 -->
     <el-dialog :title="paperPurchaseTitle" :visible.sync="paperPurchaseOpen" width="500px" append-to-body >
      <el-form :model="paperPurchaseForm" ref="paperPurchaseForm" label-width="100px">
        <el-form-item label="采购订单号" prop="purchaseOrderNumber">
          <el-input v-model="paperPurchaseForm.purchaseOrderNumber"></el-input>
        </el-form-item>
        <el-form-item label="订单日期" prop="purchaseDate">
          <el-date-picker v-model="paperPurchaseForm.purchaseDate" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="供应商" prop="purchaseSupplier">
          <el-input v-model="paperPurchaseForm.purchaseSupplier"></el-input>
        </el-form-item>
        <el-form-item label="采购业务员" prop="purchaseSalesman">
          <el-input v-model="paperPurchaseForm.purchaseSalesman"></el-input>
        </el-form-item>
        <el-form-item label="运输方式" prop="purchaseTransportation">
          <el-input v-model="paperPurchaseForm.purchaseTransportation"></el-input>
        </el-form-item>
        <el-form-item label="对应生产任务单号" prop="purchaseProductionTaskNumber">
          <el-input v-model="paperPurchaseForm.purchaseProductionTaskNumber"></el-input>
        </el-form-item>
        <el-form-item label="对应销售单号" prop="purchaseSaleOrderNumber">
          <el-input v-model="paperPurchaseForm.purchaseSaleOrderNumber"></el-input>
        </el-form-item>
        <el-form-item label="对应合同号" prop="purchaseContractNumber">
          <el-input v-model="paperPurchaseForm.purchaseContractNumber"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="paperPurchaseClose">取 消</el-button>
        <el-button type="primary" @click="submitPaperPurchase">提 交</el-button>
      </div>
    </el-dialog>
    
    <!-- 新增原材料单明细 -->
     <el-dialog :title="productionTaskTitle" :visible.sync="productionTaskOpen" width="500px" append-to-body >
      <el-form :model="productionTaskForm" ref="productionTaskForm" label-width="100px">
        <el-form-item label="版号" prop="paperNumber">
          <el-input v-model="productionTaskForm.paperNumber"></el-input>
        </el-form-item>
        <el-form-item label="需求数量" prop="paperQuantity">
          <el-input v-model="productionTaskForm.paperQuantity"></el-input>
        </el-form-item>
        <el-form-item label="比例" prop="paperRatio">
          <el-input v-model="productionTaskForm.paperRatio"></el-input>
        </el-form-item>
        <el-form-item label="实际下单数" prop="paperActualQuantity">
          <el-input v-model="productionTaskForm.paperActualQuantity"></el-input>
        </el-form-item>
        <el-form-item label="交货日期" prop="paperDeliveryDate">
          <el-date-picker v-model="productionTaskForm.paperDeliveryDate" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="paperRemarks">
          <el-input v-model="productionTaskForm.paperRemarks"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
         <el-button @click="productionTaskClose">取 消</el-button>
         <el-button type="primary" @click="submitProductionTask">确 定</el-button>
      </div>
     </el-dialog>
    
    <!-- 新增辅料采购单框 -->
    <el-dialog :title="supplementaryPurchaseTitle" :visible.sync="supplementaryPurchaseOpen" width="500px" append-to-body >
      <el-form :model="supplementaryPurchaseForm" ref="supplementaryPurchaseForm" label-width="100px">
        <el-form-item label="采购订单号" prop="supplementaryPurchaseOrderNumber">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseOrderNumber"></el-input>
        </el-form-item>
        <el-form-item label="订单日期" prop="supplementaryPurchaseDate">
          <el-date-picker v-model="supplementaryPurchaseForm.supplementaryPurchaseDate" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="供应商" prop="supplementaryPurchaseSupplier">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseSupplier"></el-input>
        </el-form-item>
        <el-form-item label="采购业务员" prop="supplementaryPurchaseSalesman">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseSalesman"></el-input>
        </el-form-item>
        <el-form-item label="运输方式" prop="supplementaryPurchaseTransportation">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseTransportation"></el-input>
          </el-form-item>
        <el-form-item label="对应生产任务单号" prop="supplementaryPurchaseProductionTaskNumber">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseProductionTaskNumber"></el-input>
        </el-form-item>
        <el-form-item label="对应销售单号" prop="supplementaryPurchaseSaleOrderNumber">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseSaleOrderNumber"></el-input>
        </el-form-item>
        <el-form-item label="对应合同号" prop="supplementaryPurchaseContractNumber">
          <el-input v-model="supplementaryPurchaseForm.supplementaryPurchaseContractNumber"></el-input>
        </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="supplementaryPurchaseClose">取 消</el-button>
          <el-button type="primary" @click="submitSupplementaryPurchase">确 定</el-button>
        </div>
     </el-dialog>
     
     <!-- 新增辅料单明细 -->
      <el-dialog :title="supplementaryProductionTaskTitle" :visible.sync="supplementaryProductionTaskOpen" width="500px" append-to-body >
        <el-form :model="supplementaryProductionTaskForm" ref="supplementaryProductionTaskForm" label-width="100px">
          <el-form-item label="物品编号" prop="supplementaryNumber">
            <el-input v-model="supplementaryProductionTaskForm.supplementaryNumber"></el-input>
          </el-form-item>
            <el-form-item label="纸箱" prop="supplementaryBox">
              <el-input v-model="supplementaryProductionTaskForm.supplementaryBox"></el-input>
            </el-form-item>
            <el-form-item label="袋子" prop="supplementaryBag">
              <el-input v-model="supplementaryProductionTaskForm.supplementaryBag"></el-input>
            </el-form-item>
            <el-form-item label="彩盒" prop="supplementaryEnvelope">
              <el-input v-model="supplementaryProductionTaskForm.supplementaryEnvelope"></el-input>
            </el-form-item>
            <el-form-item label="条码" prop="supplementaryBarcode">
              <el-input v-model="supplementaryProductionTaskForm.supplementaryBarcode"></el-input>
          </el-form-item>
          <el-form-item label="规格" prop="supplementarySpecification">
            <el-input v-model="supplementaryProductionTaskForm.supplementarySpecification"></el-input>
          </el-form-item>
          <el-form-item label="单位数量" prop="supplementaryUnitQuantity">
            <el-input v-model="supplementaryProductionTaskForm.supplementaryUnitQuantity"></el-input>
          </el-form-item>
          <el-form-item label="副单位数量" prop="supplementarySubUnitQuantity">
            <el-input v-model="supplementaryProductionTaskForm.supplementarySubUnitQuantity"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="supplementaryProductionTaskClose">取 消</el-button>
          <el-button type="primary" @click="submitSupplementaryProductionTask">确 定</el-button>
        </div>
      </el-dialog>
  </div>
</template>

<script>

export default {
  name: "ProductionTasks",
  data() {
    return {
      activeName: "first",
      paperPurchaseList: [{
        purchaseOrderNumber: "20210101001",
        purchaseDate: "2021-01-01",
        purchaseSupplier: "供应商1",
        purchaseSalesman: "业务员1",
        purchaseTransportation: "快递",
        purchaseProductionTaskNumber: "20210101001",
        purchaseSaleOrderNumber: "20210101001",
        purchaseContractNumber: "20210101001",
      },{
        purchaseOrderNumber: "20210101002",
        purchaseDate: "2021-01-01",
        purchaseSupplier: "供应商2",
        purchaseSalesman: "业务员2",
        purchaseTransportation: "快递",
        purchaseProductionTaskNumber: "20210101002",
        purchaseSaleOrderNumber: "20210101002",
        purchaseContractNumber: "20210101002",
      }],
      productionTaskList: [
        {
          paperNumber: "A123456",
          paperQuantity: 100,
          paperRatio: 1,
          paperActualQuantity: 100,
          paperDeliveryDate: "2021-01-01",
          paperRemarks: "备注",
        },
        {
          paperNumber: "B123456",
          paperQuantity: 100,
          paperRatio: 1,
          paperActualQuantity: 100,
          paperDeliveryDate: "2021-01-01",
          paperRemarks: "备注",
        },
      ],
      
      supplementaryPurchaseList: [{
        supplementaryPurchaseOrderNumber: "20210101001",
        supplementaryPurchaseDate: "2021-01-01",
        supplementaryPurchaseSupplier: "供应商1",
        supplementaryPurchaseSalesman: "业务员1",
        supplementaryPurchaseTransportation: "快递",
        supplementaryPurchaseProductionTaskNumber: "20210101001",
        supplementaryPurchaseSaleOrderNumber: "20210101001",
        supplementaryPurchaseContractNumber: "20210101001",
      },{ 
        supplementaryPurchaseOrderNumber: "20210101002",
        supplementaryPurchaseDate: "2021-01-01",
        supplementaryPurchaseSupplier: "供应商2",
        supplementaryPurchaseSalesman: "业务员2",
        supplementaryPurchaseTransportation: "快递",
        supplementaryPurchaseProductionTaskNumber: "20210101002",
        supplementaryPurchaseSaleOrderNumber: "20210101002",
        supplementaryPurchaseContractNumber: "20210101002",
      }],
      supplementaryProductionTaskList: [
        {
          supplementaryNumber: "A123456",
          supplementaryBox: 100,
          supplementaryBag: 100,
          supplementaryEnvelope: 100,
          supplementaryBarcode: "123456789",
          supplementarySpecification: "规格",
          supplementaryUnitQuantity: 100,
          supplementarySubUnitQuantity: 100,
        },
        {
          supplementaryNumber: "B123456",
          supplementaryBox: 100,
          supplementaryBag: 100,
          supplementaryEnvelope: 100,
          supplementaryBarcode: "123456789",
          supplementarySpecification: "规格",
          supplementaryUnitQuantity: 100,
          supplementarySubUnitQuantity: 100,
        },
      ],
      //
      showSearch: true,
      
      loading: false,
      showProductionTask: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      // 原材料采购
      paperPurchaseTitle:'',
      paperPurchaseForm: {},
      paperPurchaseOpen: false,
      // 原材料单明细
      productionTaskTitle:'',
      productionTaskForm: {},
      productionTaskOpen: false,
      // 辅料采购
      supplementaryPurchaseTitle:'',
      supplementaryPurchaseForm: {},
      supplementaryPurchaseOpen: false,
      // 辅料单明细
      supplementaryProductionTaskTitle:'',
      supplementaryProductionTaskForm: {},
      supplementaryProductionTaskOpen: false,
      // 加载动画
      loadingPaperPurchase: false,
      loadingProductionTask: false,
      loadingSupplementaryPurchase: false,
      loadingSupplementaryProductionTask: false,
      // 高亮行
      purchaseOrderNumber: '',
      supplementaryPurchaseProductionTaskNumber: '',
    };
  },
  methods: {
    // 显示高亮
        rowClassName({ row }) {
          return row.purchaseOrderNumber == this.purchaseOrderNumber ? 'selected-row' : ''; // 判断是否选中
        },
    // 显示高亮
        rowClassNameOne({ row }) {
          return row.supplementaryPurchaseProductionTaskNumber == this.supplementaryPurchaseProductionTaskNumber ? 'selected-row' : ''; // 判断是否选中
        },
        showTab(row){
          this.supplementaryPurchaseProductionTaskNumber = row.supplementaryPurchaseProductionTaskNumber;
          this.purchaseOrderNumber = row.purchaseOrderNumber;
        },
    // 新增原材料采购单
    handleAddPaperPurchase() {
      this.paperPurchaseOpen = true;
      this.paperPurchaseTitle = '新增原材料采购单';
      this.paperPurchaseForm = {};
    },
    // 新增原材料明细
  handleAddProductionTask() {
    this.productionTaskOpen = true;
    this.productionTaskTitle = '新增原材料单明细';
    this.productionTaskForm = {};
  },
  // 新增辅料采购单
  handleAddSupplementaryPurchase() {
    this.supplementaryPurchaseOpen = true;
    this.supplementaryPurchaseTitle = '新增辅料采购单';
    this.supplementaryPurchaseForm = {};
  },
  // 新增辅料明细
  handleAddSupplementaryProductionTask() {
    this.supplementaryProductionTaskOpen = true;
    this.supplementaryProductionTaskTitle = '新增辅料单明细';
    this.supplementaryProductionTaskForm = {};
  },
  
  // 修改原材料采购单
  handleUpdatePaperPurchase(row) {
    this.paperPurchaseOpen = true;
    this.paperPurchaseTitle = '修改原材料采购单';
    this.paperPurchaseForm = row;
  },
  // 修改原材料单明细
  handleUpdateProductionTask(row) {
    this.productionTaskOpen = true;
    this.productionTaskTitle = '修改原材料单明细';
    this.productionTaskForm = row;
  },
  // 修改辅料采购单
  handleUpdateSupplementaryPurchase(row) {
    this.supplementaryPurchaseOpen = true;
    this.supplementaryPurchaseTitle = '修改辅料采购单';
    this.supplementaryPurchaseForm = row;
  },
  // 修改辅料单明细
  handleUpdateSupplementaryProductionTask(row) {
    this.supplementaryProductionTaskOpen = true;
    this.supplementaryProductionTaskTitle = '修改辅料单明细';
    this.supplementaryProductionTaskForm = row;
  },
  
  // 删除原材料采购单
  handleDeletePaperPurchase(row) {
    this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.loadingPaperPurchase = true;
      setTimeout(() => {
        this.loadingPaperPurchase = false;
        this.paperPurchaseList.splice(this.paperPurchaseList.indexOf(row), 1);
        this.$message.success('删除成功');
      }, 1000);
    }).catch(() => {
      this.$message.error('已取消删除');
    });
  },
  // 删除原材料单明细
  handleDeleteProductionTask(row) {
    this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.loadingProductionTask = true;
      setTimeout(() => {
        this.loadingProductionTask = false;
        this.productionTaskList.splice(this.productionTaskList.indexOf(row), 1);
        this.$message.success('删除成功');
      }, 1000);
    }).catch(() => {
      this.$message.error('已取消删除');
    });
  },
  // 删除辅料采购单
  handleDeleteSupplementaryPurchase(row) {
    this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.loadingSupplementaryPurchase = true;
      setTimeout(() => {
        this.loadingSupplementaryPurchase = false;
        this.supplementaryPurchaseList.splice(this.supplementaryPurchaseList.indexOf(row), 1);
        this.$message.success('删除成功');
      }, 1000);
    }).catch(() => {
      this.$message.error('已取消删除');
    });
  },
  // 删除辅料单明细
  handleDeleteSupplementaryProductionTask(row) {
    this.$confirm('此操作将永久删除该信息, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.loadingSupplementaryProductionTask = true;
      setTimeout(() => {
        this.loadingSupplementaryProductionTask = false;
        this.supplementaryProductionTaskList.splice(this.supplementaryProductionTaskList.indexOf(row), 1);
        this.$message.success('删除成功');
      }, 1000);
    }).catch(() => {
      this.$message.error('已取消删除');
    });
  },
  
  // 提交原材料采购单
  submitPaperPurchase() {
    this.$refs.paperPurchaseForm.validate((valid) => {
      if (valid) {
        if(this.paperPurchaseTitle === '新增原材料采购单'){
        this.loadingPaperPurchase = true;
        setTimeout(() => {
          this.loadingPaperPurchase = false;
          this.paperPurchaseList.push(this.paperPurchaseForm);
          this.paperPurchaseForm = {};
          this.$message.success('新增成功');
        }, 1000);
         this.paperPurchaseOpen = false;
      } else if(this.paperPurchaseTitle === '修改原材料采购单'){
        this.loadingPaperPurchase = true;
        setTimeout(() => {
          this.loadingPaperPurchase = false;
          this.paperPurchaseList.map((item, index) => {
            if (item.purchaseOrderNumber === this.paperPurchaseForm.purchaseOrderNumber) {
              this.paperPurchaseList.splice(index, 1, this.paperPurchaseForm);
              this.paperPurchaseForm = {};
              this.$message.success('修改成功');
            }
          });
        }, 1000);
        this.paperPurchaseOpen = false; 
      }
      }
    })
  },
  
  // 提交原材料单明细
  submitProductionTask() {
    this.$refs['productionTaskForm'].validate((valid) => {
      if (valid) {
        if(this.productionTaskTitle === '新增原材料单明细'){
          this.loadingProductionTask = true;
          setTimeout(() => {
            this.loadingProductionTask = false;
            this.productionTaskList.push(this.productionTaskForm);
            this.productionTaskForm = {};
            this.$message.success('新增成功');
          }, 1000);
          this.productionTaskOpen = false;
        } else if(this.productionTaskTitle === '修改原材料单明细'){
          this.loadingProductionTask = true;
          setTimeout(() => {
            this.loadingProductionTask = false;
            this.productionTaskList.map((item, index) => {
              if (item.paperNumber === this.productionTaskForm.paperNumber) {
                this.productionTaskList.splice(index, 1, this.productionTaskForm);
                this.productionTaskForm = {};
                this.$message.success('修改成功');
              }
            });
          }, 1000);
          this.productionTaskOpen = false;
        }
      }
    })
  },
  
  // 提交辅料采购单
  submitSupplementaryPurchase() {
    this.$refs['supplementaryPurchaseForm'].validate((valid) => {
      if (valid) {
        if(this.supplementaryPurchaseTitle === '新增辅料采购单'){
          this.loadingSupplementaryPurchase = true;
          setTimeout(() => {
            this.loadingSupplementaryPurchase = false;
            this.supplementaryPurchaseList.push(this.supplementaryPurchaseForm);
            this.supplementaryPurchaseForm = {};
            this.$message.success('新增成功');
          }, 1000);
          this.supplementaryPurchaseOpen = false;
        } else if(this.supplementaryPurchaseTitle === '修改辅料采购单'){
          this.loadingSupplementaryPurchase = true;
          setTimeout(() => {
            this.loadingSupplementaryPurchase = false;
            this.supplementaryPurchaseList.map((item, index) => {
              if (item.supplementaryPurchaseOrderNumber === this.supplementaryPurchaseForm.supplementaryPurchaseOrderNumber) {
                this.supplementaryPurchaseList.splice(index, 1, this.supplementaryPurchaseForm);
                this.supplementaryPurchaseForm = {};
                this.$message.success('修改成功');
              }
            });
          }, 1000);
          this.supplementaryPurchaseOpen = false;
        }
      }
    })
  },
  
  // 提交辅料单明细
  submitSupplementaryProductionTask() {
    this.$refs['supplementaryProductionTaskForm'].validate((valid) => {
      if (valid) {
        if(this.supplementaryProductionTaskTitle === '新增辅料单明细'){
          this.loadingSupplementaryProductionTask = true;
          setTimeout(() => {
            this.loadingSupplementaryProductionTask = false;
            this.supplementaryProductionTaskList.push(this.supplementaryProductionTaskForm);
            this.supplementaryProductionTaskForm = {};
            this.$message.success('新增成功');
          }, 1000);
          this.supplementaryProductionTaskOpen = false;
        } else if(this.supplementaryProductionTaskTitle === '修改辅料单明细'){
          this.loadingSupplementaryProductionTask = true;
          setTimeout(() => {
            this.loadingSupplementaryProductionTask = false;
            this.supplementaryProductionTaskList.map((item, index) => {
              if (item.supplementaryNumber === this.supplementaryProductionTaskForm.supplementaryNumber) {
                this.supplementaryProductionTaskList.splice(index, 1, this.supplementaryProductionTaskForm);
                this.supplementaryProductionTaskForm = {};
                this.$message.success('修改成功');
              }
            });
          }, 1000);
          this.supplementaryProductionTaskOpen = false;
        }
      }
    })
  },
  
  // 关闭原材料采购单框
  paperPurchaseClose() {
    this.paperPurchaseOpen = false;
    this.paperPurchaseForm = {};
  },
  // 关闭原材料单明细框
  productionTaskClose() {
    this.productionTaskOpen = false;
    this.productionTaskForm = {};
  },
  // 关闭辅料采购单框
  supplementaryPurchaseClose() {
    this.supplementaryPurchaseOpen = false;
    this.supplementaryPurchaseForm = {};
  },
  // 关闭辅料单明细框
  supplementaryProductionTaskClose() {
    this.supplementaryProductionTaskOpen = false;
    this.supplementaryProductionTaskForm = {};
  },
  

  getList() {},
  resetForm(){},
  }
}
</script>
<style>
.selected-row {
  background-color: yellow !important;
  /* 选中行的背景颜色 */
}
</style>
